<template>
  <!-- 我的奖品 -->
  <view class="my_prize">
    <view
      class="box_myhx"
      @touchstart="touchStart"
      @touchend="touchEnd"
    >
      
      <!-- <van-empty
        description="暂无数据"
        v-if="list_my.length == 0"
      /> -->
      <view class="hxjp_box" v-for="(item, index) in list_my" :key="index" @click.stop>
        <view class="myjpbox3" @click="whxfn1(item, index)">
          <view class="flexbetween mb_16">
            <view class="drawlevel fw">{{ item.level_name }}</view>
            <view class="hxstatus hxstatus2" v-if="item.status==0">未核销</view>
            <view class="hxstatus" v-else>已核销</view>
          </view>
          <view class="f28 c_696969 pb_20 borderb">{{ item.draw_name }} x1</view>
          <view class="pt_10" v-if="item.status==0">
            <span class="f28 c_696969">兑奖期限：</span>
            <span class="c_000 f28">
              {{ parseTime(item.task_draw.startime, "{y}-{m}-{d}") }} 至 {{
                parseTime(item.task_draw.endtime, "{y}-{m}-{d}")
              }}
            </span>
          </view>
          <view class="pt_10" v-else>
            <view class="flex pt_20 f28 flexitem">
              <view class="flextitle c_696969">活动：</view>
              <view class="flexcontent c_000">{{ item.task.name }}</view>
            </view>
            <view class="flex pt_20 f28 flexitem">
              <view class="flextitle c_696969">核销方式：</view>
              <view class="flexcontent c_000">{{ item.task_draw.draw_type_name }}</view>
            </view>
            <view class="flex pt_20 f28 flexitem">
              <view class="flextitle c_696969">核销时间：</view>
              <view class="flexcontent c_000">
                <span v-if="item.last_time">
                    <span v-if="item.address_time">{{
                      new Date(item.last_time).getTime() >
                      new Date(item.address_time).getTime()
                        ? item.last_time
                        : item.address_time
                    }}</span>
                    <span v-else>{{ item.last_time || "-" }}</span>
                  </span>
                  <span v-else-if="item.address_time">{{
                    item.address_time || "-"
                  }}</span>
                  <span v-else>-</span>
              </view>
            </view>
            <view class="flex pt_20 f28 pb_20 flexitem borderb">
              <view class="flextitle c_696969">核销备注：</view>
              <view class="flexcontent c_000" v-if="item.more">{{ item.more.beizhu || "无" }}</view>
              <view class="flexcontent c_000" v-else>无</view>
            </view>
            <view class="flex pt_20 f28 flexitem">
              <view class="flextitle c_696969">收货地址：</view>
              <view class="flexcontent c_000" v-if="item.more"> {{ item.more.name }} {{ item.more.phone }}</view>
              <view class="flexcontent c_000" v-else>-</view>
            </view>
            <view class="flex pt_20 f28 flexitem">
              <view class="flextitle c_696969"></view>
              <view class="flexcontent c_000" v-if="item.more">
                {{ item.more.province }}{{ item.more.city }}{{ item.more.area }}{{ item.more.address }}</view>
              <view class="flexcontent c_000" v-else>-</view>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>
  
<script>
import { myDraw, csmyDraw } from "@/api/task";
export default {
  name: "myPrize",
  data() {
    return {
      list_my: [],
      page: 1,
      num: 20
    }
  },
  methods: {
    async init() {
      const task = uni.getStorageSync('task_info');
      
      const state = task.status;
      if (state == 0) {
        let res = await csmyDraw({ id: task.id, page: this.page, num: this.num, istest });
        this.list_my = res.data.list;
      } else {
        const res = await myDraw({ id: task.id, page: this.page, num: this.num, istest });
        this.list_my = res.data.list;
      }
    },
    whxfn1(item, index) {
      if (item.status!==0) return;
      const task = uni.getStorageSync('task_info');
      this.$router.push(
        "/cashaprize?id=" +
          task.id +
          "&index=" +
          encodeURIComponent(index) +
          "&obj=" +
          encodeURIComponent(JSON.stringify(item))
      );
    },
    touchStart() {
        console.log(1);
    },
    touchEnd() {
        this.num += 20;
        this.init();
    }
  },
  created() {
    this.init();
  }
};
</script>
  
<style lang="scss" scoped>
.box_myhx {
  // background-color: #F4F8FD;
  background: #ffffff;
  // box-shadow: 0px 6px 20px 2px rgba(0, 0, 0, 0.16);
  max-height: calc(100vh - 2.5rem);
  .hxjp_box {
    margin-top: 20px;
  }
  
    .myjpbox3 {
      margin-top: 20px;
      background-color: #F4F8FD;
      border-radius: 12px;
      padding: 20px;
      .drawlevel{
        font-size: 28px;
      }
      .hxstatus{
        font-size: 26px;
        border-radius: 40px;
        background-color: #F2F2F2;
        border: 1px solid #868686;
        color: #868686;
        padding: 4px 26px;
      }
      .hxstatus2{
        border-color: #B90000;
        color: #B90000;
        background-color: #FDEDED;
      }
      .borderb{
        border-bottom: 1px dashed #707070;
      }
    }
}
</style>
  